<template>
	<view class="page">
		<view class="search-title">
			<view class="search-title-left">
				<view class="search-title-left-item">
					{{dateList}}
				</view>
			</view>
			<view class="search-title-right">
				<view class="search-title-right-item">
					{{workList}}
				</view>
				<uni-icons type="arrowdown"  size="36rpx"></uni-icons>
			</view>
			
		</view>
		<view class='bg-grey'>
			
			<view class="conf-list">
				<view class="conf-list-item" v-for="(item,index) in listData" :key="index">
					<view class="conf-list-card" @click="gotodo(item)">
						<view class="conf-list-title">
							<view>
								<text>任务名称：</text>
								{{item.name}}
							</view>
							
							<view>
								<text>发起人：</text>
								<text>{{item.applyer}}</text>
							</view>
						</view>
						
						<view class="conf-list-content1">
							<view>
								<text>单号：</text>
								<text>{{item.tableId==null?'':item.tableId}}</text>
							</view>
							<view>
								<text>所属流程：</text>
								{{item.processName}}
							</view>
						</view>
						<view class="conf-list-content1">
							<view>
								<text>优先级：</text>
								<text v-if="item.priority==0" style="color: green;">普通</text>
								<text v-if="item.priority==1" style="color: orangen;">重要</text>
								<text v-if="item.priority==2" style="color: red;">紧急</text>
							</view>
							<view>
								<text>状态：</text>
								<text v-if="item.isSuspended==false" style="color: green;">已激活</text>
								<text v-if="item.isSuspended==true" style="color: orangen;">已挂起</text>
							</view>
							
						</view>
						<view class="conf-list-content">
							<text>创建日期：</text>
							<text>{{item.createTime}}</text>
						</view>
						<view class="conf-list-content1" style="border-top: solid 1px #e5e5e5;">
							<view style="width: 50%;height: 80upx;line-height: 80upx;text-align: center;border-right: solid 1px #e5e5e5;font-size: 28upx;" @click.stop="inputBack(item)">拒绝</view>
							<view style="width: 50%;height: 80upx;line-height: 80upx;text-align: center;color: rgb(87, 133, 170);font-size: 28upx;" @click.stop="inputPass(item)">同意</view>
						</view>
					</view>
				</view>
			</view>
			<view>
				<uni-popup ref="inputPass" type="dialog">
					<uni-popup-dialog ref="passClose"  mode="input" title="审批通过" :value="comment"
						placeholder="审批意见" @confirm="passTask()"></uni-popup-dialog>
				</uni-popup>
			</view>
			<view>
				<uni-popup ref="inputBack" type="dialog">
					<uni-popup-dialog ref="backClose"  mode="input" title="审批驳回" :value="comment"
						placeholder="审批意见" @confirm="backTask()"></uni-popup-dialog>
				</uni-popup>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		computed: {
			...mapState(['companyCode'])
		},
		data() {
			return {
				dateList:'全部',
				workList: '进行中',
				text: '暂无数据',
				title: '下拉刷新 + 加载更多',
				data: [],
				comment:'',
				listData: [],
				pageNo: 0,
				id:'',
				procInstId:'',
				endFlag: false,
				filter: "",
				loadMoreText: "加载中...",
			};
		},

		onShow() {
			this.loadMoreText = "加载更多";
		},
		onLoad(e) {
				this.initData();
		},
		mounted(){
		},
		onUnload() {
			this.max = 0;
			// this.data = [],
			this.listData = [];
		},
		onReachBottom() {
			if (this.endFlag == true) {
				this.loadMoreText = "已显示全部数据"
				uni.showToast({
					icon: 'none',
					title: this.loadMoreText
				});
				return;
			}
			setTimeout(() => {
				this.listData = []
				this.getList()
			}, 300);
		},
		onPullDownRefresh() {
			
			uni.stopPullDownRefresh();
		},
		methods: {
			
			initData() {
				setTimeout(() => {
					this.getList();
					uni.stopPullDownRefresh();
				}, 300);
			},
			inputPass(e) {
				this.$refs.inputPass.open(e)
				this.id = e.id
				this.procInstId = e.procInstId
			},
			inputBack(e) {
				this.$refs.inputBack.open(e)
				this.id = e.id
				this.procInstId = e.procInstId
			},
			gotodo(e){
				let info = {
					"vbeln":e.tableId,
					'id':e.id,
					'procInstId':e.procInstId
				};
				console.log(info)
				uni.navigateTo({
					url: '/packageA/mcloud/todoDetailed?info=' + encodeURIComponent(JSON.stringify(info))
				});
			},
           //产品列表
			getList() {
				this.listData=[]
				let url = '/dcloud/actTask/todoList'
				this.pageNo+=1
				this.$http.post(url, {
					
				}).then(res => {
					if (res.data.success) {
						this.listData=res.data.result;
						this.listData.forEach(a =>{
						})
						if (this.listData.length <100) {
							this.endFlag = true;
							this.loadMoreText = "已显示全部数据"
						}
					}
				}).catch(err => {
					console.log(err);
				});
			},
			passTask(v){
				console.log(this.id)
				let url = '/dcloud/actTask/pass'+'?' + 'id='+this.id + '&'+ 'procInstId=' + this.procInstId +'&'+ 'type=0' +'&'+ 'sendMessage=true'  + '&' + 'comment=' + v
				this.$http.post(url).then(res => {
					if (res.data.success) {
						this.getList();
					}else{
						this.$tip.error(res.data.message)
					}
				})
				this.$refs.passClose.close()
			},
			backTask(v){
				let url = '/dcloud/actTask/back'+'?' + 'id='+this.id + '&'+ 'procInstId=' + this.procInstId +'&'+ 'type=1' +'&'+ 'sendMessage=true'+ '&' + 'comment=' + v
				this.$http.post(url).then(res => {
					if (res.data.success) {
						this.getList();
					}else{
						this.$tip.error(res.data.message)
					}
				})
				this.$refs.backClose.close()
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .uni-select {
		font-size: 14px;
		border: 0px solid #dd524d;
		box-sizing: border-box;
		border-radius: 0px;
		padding: 0 5px;
		padding-left: 10px;
		position: relative;
		display: flex;
		-webkit-user-select: none;
		user-select: none;
		flex-direction: row;
		align-items: center;
		/*    border-bottom: solid 1px #e5e5e5; */
		border-left: solid 1px #e5e5e5;
		width: 100%;
		flex: 1;
		height: 50upx;
	}

	::v-deep .uni-stat__actived {
		width: 150rpx;
		flex: 1;
	}

	page {
		background: #FFFFFF;
		width: 750upx;
		overflow-x: hidden;
	}

	.search-title {
		display: flex;
		padding: 5upx 0upx;

		.search-title-left {
			flex: 1;
			height: 60upx;
			display: flex;
			justify-content: center;
			border-right: solid 1px #e5e5e5;

			.search-title-left-item {
				font-size: 26upx;
				line-height: 62upx;
				// margin-right: 15upx;
			}
		}
		.search-title-left:active{
			background-color: #f5f5f5;
		}

		.search-title-right {
			flex: 1;
			height: 60upx;
			display: flex;
			justify-content: center;
			border-right: solid 1px #e5e5e5;
			.search-title-right-item {
				font-size: 26upx;
				line-height: 62upx;
				margin-right: 15upx;
			}
		}
		.search-title-right:acitve{
			background-color: #f5f5f5;
		}
	}

	.bg-grey {
		background-color: rgb(234, 231, 231);
		padding: 2upx 20upx;

		.time-flex {
			display: flex;
			flex-wrap: wrap;

			.time-flex-item {
				width: 50%;
				text-align: center;
				height: 100upx;
				padding: 10upx 30upx;

				.time-flex-item-padding {
					background: #FFFFFF;
					height: 80upx;
					color: black;
					border-radius: 14upx;
					line-height: 80upx;
				}
				.time-flex-item-padding:active {
						background-color: #f5f5f5;
					}
			}
		}

		.search-list {

			display: flex;
			height: 140upx;
			padding: 10upx 0upx 10upx 0upx;

			.search-list-left {
				flex: 1;
				text-align: center;
				padding-right: 20upx;
				height: 120upx;

				.search-list-left-padding {

					background: rgb(146, 212, 2);
					border-radius: 14upx;
					height: 120upx;
					padding: 10upx 0upx;
				}
			}

			.search-list-right {
				flex: 1;
				text-align: center;
				padding-left: 20upx;
				height: 120upx;

				.search-list-right-padding {
					background: #34A4DF;
					border-radius: 14upx;
					height: 120upx;
					padding: 10upx 0upx;
				}

			}
		}

		.conf-list {
			margin-top: -10upx;

			// 	height: 180upx;
			// background: greeen;
	// 		.conf-list-item:active {	// 	background-color: #f5f5f5;	// }
			.conf-list-item {
				height: 360upx;
				background: #FFFFFF;
				color: black;
				border-radius: 20upx;

				.conf-list-card {
					height: 360upx;
					border-radius: 20upx;
					margin-top: 20upx;

					.conf-list-title {
						height: 60upx;

						display: flex;
						padding: 6upx 20upx 0 20upx;
						justify-content: space-between;
						border-radius: 20upx 20upx 0upx 0upx;
						border-bottom: solid 1px #e5e5e5;
						font-size: 30upx;
						// padding: 10upx 0 0 0;
						// line-height: 30upx;
					}

					.conf-list-content {
						height: 60upx;
						padding: 0 20upx;
						font-size: 26upx;
					}

					.conf-list-content1 {
						height: 80upx;
						padding: 0 20upx;
						font-size: 26upx;
						display: flex;
						justify-content: space-between;
						view{
							font-size: 26upx;
						}
					}
				}
			}
		}
	}


	.header {
		display: flex;
		flex-direction: row;
		padding: 10px 15px;
		align-items: center;
		/* background-color: #b6bbc3; */
		background-image: linear-gradient(#34A4DF, #34A4DF, #2bace7);
	}

	.shaixuan {
		/* display: flex; */
		/* background-color: #a8acb4; */
		background-image: linear-gradient(#2bace7, #64c7fc, #8edffc);
		height: 400rpx;
		flex-direction: column;
	}

	.input {
		flex: 2;
		padding: 0 5px;
		height: 24px;
		line-height: 24px;
		font-size: 16px;
		color: #000;
	}

	.icon {
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-left: 10px;
	}

	.bottom {
		position: fixed;
		bottom: 90upx;
		right: 50upx;
		width: 90upx;
		height: 90upx;
	}

	




</style>
